package com.test.controller;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


import com.test.comment.FightBean;
import com.test.comment.SingerBean;
import com.test.dao.JudgeDao;



@Controller
@ResponseBody
@RequestMapping("/judge")
public class JudgesScoreController {
    Logger logger = Logger.getLogger(getClass());
	@Autowired
	JudgeDao judgeDao;
	@RequestMapping("/imgs")
	public List<SingerBean> showImgs() {
		FightBean	res = judgeDao.findFight();
		SingerBean s1= judgeDao.findSinger(res.getSidOne());
		SingerBean s2= judgeDao.findSinger(res.getSidTwo());
		List<SingerBean> list = new ArrayList<>();
		list.add(s1);
		list.add(s2);
		return list;
	}
	@RequestMapping("/rid")
	public FightBean showRid() {
		FightBean	res = judgeDao.findFight();
		return res;
	}
	
	
		@RequestMapping("/a")
		public ModelAndView goactive() {
			return new ModelAndView("JudgesScore");
		}
		
		
	
		@RequestMapping("/score")
			public Map<String, String> showScore(int sid,String score1,int rid) {
			logger.debug("===========i:"+sid);
			logger.debug("===========j:"+score1);
			logger.debug("===========k:"+rid);
			judgeDao.insertScore(sid, score1, rid);
			Map<String, String> map = new HashMap<>();
			map.put("msg", "success");
			return map;
		}
		@RequestMapping("/score2")
		public Map<String, String> showScore2(int sid2,String score2,int rid2) {
		logger.debug("===========i:"+sid2);
		logger.debug("===========j:"+score2);
		logger.debug("===========k:"+rid2);
		judgeDao.insertScore(sid2, score2, rid2);
		Map<String, String> map = new HashMap<>();
		map.put("msg", "success");
		return map;
		
	}
	
}
